import request from "@/utils/request"

const DICT_DETAIL_BASE_URL = "/api/object/com.siline.chimes/ChimesDictDetail"

class DictDetailAPI {
  /**
   * 获取字典详情分页列表
   *
   * @param data 查询参数
   * @returns 字典详情分页结果
   */
  static getPage(data: QueryCondition = {}) {
    return request<any, ResponseData<PageResult<DictDetailVO[]>>>({
      url: `${DICT_DETAIL_BASE_URL}/paged_query`,
      method: "post",
      data,
    })
  }

  /**
   * 获取字典详情表单数据
   *
   * @param id 字典详情ID
   * @returns 字典详情表单数据
   */
  static getFormData(id: number) {
    return request<any, ResponseData<DictDetailForm>>({
      url: `${DICT_DETAIL_BASE_URL}/select/${id}`,
      method: "get",
    })
  }

  /**
   * 新增字典详情
   *
   * @param data 字典详情表单数据
   * @returns 请求结果
   */
  static add(data: DictDetailForm) {
    return request({
      url: `${DICT_DETAIL_BASE_URL}/insert`,
      method: "post",
      data: data,
    })
  }

  /**
   * 修改字典详情
   *
   * @param id 字典详情ID
   * @param data 字典详情表单数据
   * @returns 请求结果
   */
  static update(data: DictDetailForm) {
    return request({
      url: `${DICT_DETAIL_BASE_URL}/update`,
      method: "post",
      data: data,
    })
  }

  /**
   * 删除字典详情
   *
   * @returns 请求结果
   */
  static deleteBy(data: QueryCondition) {
    return request({
      url: `${DICT_DETAIL_BASE_URL}/delete_by`,
      method: "post",
      data,
    })
  }
}

export default DictDetailAPI

/**
 * 字典详情分页对象
 */
export interface DictDetailVO {
  create_by?: string
  create_time?: Date
  detail_id?: number
  dict_id?: number
  dict_sort?: number
  label?: string
  update_by?: string
  update_time?: Date
  value?: any
}

/**
 * 字典详情
 */
export interface DictDetailForm {
  detail_id?: number
  dict_id?: number
  dict_sort?: number
  label?: string
  value?: any
}
